from Case.python_ui.Common.basepage import Basepage
from Case.python_ui.PageLocate.add_funds_locator import AddFunsLocator
import  time

class  AddFundsPages(Basepage):

    def  enter_add_funds_page(self):
         doc='进入到addfunds主页'
         time.sleep(5)
         for i in range(3):
            try:
                self.wait_elevisble(AddFunsLocator.fund_management_tab,doc)
                self.click_element(AddFunsLocator.fund_management_tab,doc)
                self.wait_elevisble(AddFunsLocator.add_funds_tab,doc)
                self.click_element(AddFunsLocator.add_funds_tab,doc)
                break
            except:
                self.refresh_page()
                time.sleep(5)
                continue



    def check_add_funds_page(self):
        doc='检查addfunds页面'
        self.enter_add_funds_page()
        self.wait_elevisble(AddFunsLocator.cash_account,doc)
        account=self.get_element(AddFunsLocator.cash_account,doc).text
        fund=self.get_element(AddFunsLocator.fund_added,doc).text
        return account,fund


    def user_manual_recharge(self):
        doc='用户充值'
        self.enter_add_funds_page()
        self.wait_elevisble(AddFunsLocator.cash_account,doc)
        self.send_keys(AddFunsLocator.funds_input,'100',doc)
        self.click_element(AddFunsLocator.submit_button,doc)



